package Text01.Text02;

import java.sql.*;

public class Text {
    //4:用 PreparedStatement 实现删除功能（表随意）

    public static void main(String[] args) {
        String url="jdbc:mysql://127.0.0.1:3306/kgc76?useUnicode=true&characterEncoding=utf-8&useSSL=true";
        String user = "root";
        String pwd = "123456";
        Connection con = null;
        Statement statement = null;
        ResultSet resultSet = null;
        int result = 0;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection(url,user,pwd);
            statement = con.createStatement();
            result = statement.executeUpdate("DELETE FROM s_student WHERE stuno = 214;");
            if (result>0){
                System.out.println("删除成功");
            }else {
                System.out.println("删除失败");
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            try {
                statement.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            try {
                con.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}
